function [F,info] = DBVTest(N)
% DBVTEST - 测试对DBV函数的计算
%   输出变量：
%   F：最优值数列
%   info：相关info
%   输入变量：
%   N  相应的n的数组

%N = [4 20 40 60];
[stop , n ] =check(N);
if stop, error('x must be a real valued vector'), end

for i = 1:n,
    x0 = zeros(N(i),1);
    n = N(i);
    for j = 1:N(i),
        t = i/(n+1);
        x0(j) = t*(t-1);
    end
    x = zeros(N(i),5);
    maxstep = 10000;
    % 阻尼Newton法。
    %'damping newton'
    opts = [0,1e-8,1e-8,1e-8,maxstep,100];
    [x(:,1),F(i,1),info(:,1,i)]=Newton(@DBV,x0,opts);
    %'multi Newton'
    opts = [1,1e-8,1e-8,1e-8,maxstep,100];
    [x(:,2),F(i,2),info(:,2,i)]=Newton(@DBV,x0,opts);
    %'Quasi Newton:SR1'
    opts = [2,1e-8,1e-8,1e-8,maxstep,100];
    [x(:,3),F(i,3),info(:,3,i)]=Newton(@DBV,x0,opts);
    %'Quasi Newton:BFGS'
    opts = [3,1e-8,1e-8,1e-8,maxstep,100];
    [x(:,4),F(i,4),info(:,4,i)]=Newton(@DBV,x0,opts);
    %'Quasi Newton:DFP'              
    opts = [4,1e-8,1e-8,1e-8,maxstep,100];
    [x(:,5),F(i,5),info(:,5,i)]=Newton(@DBV,x0,opts);
    %'DBV',N(i),F,info,
    
end

end
function [err,n] = check(x)
% CHECK - check x
%   
    err = 0; sx = size(x); n = max(sx);
    if  (min(sx) ~= 1) | ~isreal(x) | any(isnan(x(:))) | isinf(norm(x(:))) 
        err = -1; 
    end    
end
